import { ajax } from '@/utils'

const baseUrl = '/system/post'

export default {
  getPostPage(...args: IGetPostPageReq): Promise<IGetPostPageRes> {
    return ajax.post(`${baseUrl}/page`, args[0])
  },
  createPost(...args: ICreatePostReq): IVoidRes {
    return ajax.post(`${baseUrl}/create`, args[0])
  },
  updatePost(...args: IUpdatePostReq): IVoidRes {
    return ajax.put(`${baseUrl}/update/${args[0]}`, args[1])
  },
  deletePost(...args: IDeleteReq): IVoidRes {
    return ajax.delete(`${baseUrl}/delete`, { data: args[0] })
  },
  exportPostPage(...args: IGetPostPageReq): IExportRes {
    return ajax.post(`${baseUrl}/export`, args[0], { responseType: 'blob' })
  }
}
